package beer.model.dao;

import java.sql.SQLException;
import java.util.ArrayList;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import beer.model.domain.Beer;



public class BeerDAO {
	
	private SqlMapClientTemplate sqlMap;
	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMap){
		this.sqlMap = sqlMap;
	}
	
	public void insertBeer(Beer beer) throws SQLException{
		sqlMap.insert("insertBeer", beer);
	}
	public int updateBeer(Beer beer) throws SQLException{
		return sqlMap.update("updateBeer", beer);
	}
	
	public int deleteBeerById(String beer_id) throws SQLException{
		return sqlMap.delete("deleteBeerById", beer_id);
	}
	public Beer selectBeerById(String beer_id) throws SQLException{
		return (Beer)sqlMap.queryForObject("selectBeerById", beer_id);
	}
	
	public ArrayList<Beer> selectAllBeer() throws SQLException{
		return (ArrayList<Beer>)sqlMap.queryForList("selectAllBeer");
	}
	/*
	public Beer selectBeerByIdJoinBook(String Beer_id) throws SQLException{
		return (Beer)sqlMap.queryForObject("selectBeerByIdJoinBook", Beer_id);
	}
	public ArrayList<Beer> selectAllBeerRentingBooks() throws SQLException{
		return (ArrayList<Beer>)sqlMap.queryForList("selectAllBeerJoinBook");
	}
	*/
}
